<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			/*//定义字符集-单次匹配
			//【0-9】：0到9之间任意一个数字
			var reg1 = /[0-9]/;
			var str3 = "2015-3-23";
			var result = str3.match(reg1);
			console.log(result)		//找的是2因为它找到一个符合条件的就结束了*/
			//[a-e]：表示a-e这些字符中的莫一个字符
			var reg = /[a-e]/;
			var str1 = "hello";
			var result1 = str1.match(reg);
			console.log(result1);
			
			//特殊字符
			//+:前面那个单元出现1次或多次
			//+: 前面那个单元出现一次或多次
			var reg = /[0-9]+/;
			var str = "hello2-24";
			var result = str.match(reg);
			console.log(result);
			var reg = /[0-9]+/g;	//全局匹配
			var str = "hello2-24";
			var result = str.match(reg);
			console.log(result);
			
			//*：代表前面那个单元出现0次或者多次(任意次数)
			var reg = /go*gle/;
			var str= "gooooooooooooooooogle";
			var result = str.match(reg);
			console.log(result);
			
			//?:前面那个单元出现0次或一次
			var reg = /wo?rld/;
			var str = "wrld";
			var result = str.match(reg);
			console.log(result);
			
			//.:匹配除了换行符\n之外的任何一个字符   .*
			var reg = /.*/;	
			var str = "fapohij9ifwesho451\n641616*-/*--+";	//[ "fapohij9ifwesho451" ]
			
			
			//|:两项之间的一个选项
			var reg = /milk|fish/;
			var str = "cat like eat fish and milk";		//fish加一个g就可以都打印
			
			//\:这个符号是用来转义
			//把符号的特殊意义给去掉，只保留最本质的意思  \.这样就表示一个单纯的店  
			var reg = /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/;
			var str = "192.138.22.3";	// [ "192.138.22.3" ]
			
			//$: 匹配输入字符串的结尾位置
			//^: 匹配输入字符串的开始位置
			var reg = /^babana/;	//这个正则要求babana出现在字符串的开始位置null
			var reg = /^monkey/;	//[“monkey”]
			var reg = /babana$/;	// [ "babana" ]
			var str = "monkey and babana";
			
			//{0-9}表示前面数字出现的次数
			var reg = /13[0-9]{9}/;	
			var str = "13121212121java ";	//[ "13121212121" ]
			
			//我们想要后面这个独立手机号
			//^和$限制被匹配的内容进行”完整匹配“,前后不再有其他的字符
			var reg = /^13[0-9]{9}$/;
			var str = "13606425524";	//[ "13606425524" ]
			
			//模式修正符组成
			//i:忽略大小写
			var reg = /[a-z]+/i;
			var str = "helloBEIJING";	//[ "helloBEIJING" ]
			//g:全局匹配
			var reg = /[0-9]+/g;
			var str = "1997-02-24 00-00-00";	//[ "1997", "02", "24", "00", "00", "00" ]
			
			var reg = /[0-7]+/;
			
			/*  \d	表示[0-9]
				\D	表示[^0-9]
				\w	表示[a-zA-Z0-9]
				\W	表示[^a-zA-Z0-9]
				\s	表示空格
				\S	表示非空格
				\b	表示单词边界
				\B	表示非单词边界
			*/
			
			var reg = /\d+/g;
			var str = "2018-08-20";		//[ "2018", "08", "20" ]
			
			var reg = /\D+/g;
			var str = "2018-08-20";		//[ "-", "-" ]
			
			var reg = /\w+/g;
			var str = "166fasuhgdsium-+_6+45";		[ "166fasuhgdsium", "_6", "45" ]
			
			var reg = /\s+/g;
			var str = "ahksfias   dajhsoi  dajsoi  dasjoio ";		//表示空格 [ "   ", "  ", "  ", " " ]
			
			var reg = /\bis\b/g;
			var str = "what is a is a isfuck ";		//[ "is", "is" ]表示这种独立的is
			var newstr = str.replace(reg , "was");
			var reg = /\bis\B/
			var str = "what is a is a isfuck ";		//[ "is", "is" ]表示这种独立的is
			
			
			//限定字符
			//{m}:其前一单元严格出现m次
			//{m，}：前至少出现m次，后无限
			//{m，n}：前至少出现m次，后出现n次
			
			var result = str.match(reg);
			console.log(result);
		</script>
	</head>
	<body>
	</body>
</html>
